/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package spaceshooter;

import it.randomtower.engine.ME;
import it.randomtower.engine.ResourceManager;
import it.randomtower.engine.entity.Entity;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

/**
 *
 * @author Bensch
 */
public class SquidMonster extends Entity {
    public static String SQID_MONSTER = "monster";
    private int frameCount = 0;
    private int nextFrame = 500;
    private int frame = 0;
    private int health;
    
    public SquidMonster(float x, float y) {
        super(x,y);
        Image monster = ResourceManager.getImage("squidMonster");
        setHitBox(8, 1, 22, 30);
        setGraphic(monster);
        addType(SQID_MONSTER);
        health = 100;
    }
    
    @Override
    public void update(GameContainer gc, int delta) throws SlickException {
        super.update(gc, delta);
        frameCount += delta;
        if(frameCount >= nextFrame) {
            frameCount -= nextFrame;
            frame++;
            if(frame % 2 == 0) {
                setGraphic(ResourceManager.getImage("squidMonsterMove"));
            }
            else {
                setGraphic(ResourceManager.getImage("squidMonster"));
            }
        }
        y += (.6 * delta);
        if(y > ME.world.getHeight()) {
            this.destroy();
        }
    }
    
    @Override
    public void collisionResponse(Entity e) {
        health = 50;
        if(health <= 0) {
            this.destroy();
        }
    }
    
}
